package com.searchingmodule;

import java.util.HashMap;

import com.model.DataModel;
import com.recommender.Recommender;

public class RecommendingElement {
	
	private HashMap<String, String> contextMap;
	private DataModel datamodel;
	private Recommender recommender;
	
	public boolean isUserBased=false;
	private long userID=Integer.MIN_VALUE;
	private String keyword=null;
	
	
	public void setDataModel(DataModel datamodel)
	{
		this.datamodel=datamodel;
	}
	public void setRecommender(Recommender recommender)
	{
		this.recommender=recommender;
	}
	
	public int saveUserFeedback(long imageID,String keyword,HashMap<String, String> contextMap)
	{
		try {
				
			datamodel.saveUserFeedback(contextMap, Integer.MIN_VALUE, keyword, "", imageID);
			return 1;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return 0;
		}
	
	}
	
	public int saveUserFeedback(long userID,long imageID,String keyword,HashMap contextMap)
	{
		try {
				
			datamodel.saveUserFeedback(contextMap, userID, keyword, "", imageID);
			return 1;
		} catch (Exception e) {
			// TODO Auto-generated catch blockS
			e.printStackTrace();
			return 0;
		}
	
	}
	
	public String getRecommendedImages(long userID,String keyword,HashMap<String, String> contextMap)
	{
		this.contextMap=contextMap;
		return null;
	}

	public String getRecommendedImages(String keyword,HashMap<String, String> contextMap)
	{
		this.contextMap=contextMap;
		return null;
	}
	public int saveUserFeedback(long imageID)
	{
		try {
			if(isUserBased)
			{
				return datamodel.saveUserFeedback(contextMap, userID, keyword, "", imageID);
				
			}
			else
			{
				return datamodel.saveUserFeedback(contextMap,Integer.MIN_VALUE,keyword,"",imageID);
			}
	
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return 0;
		}
	
	}
	public RecommendingElement() {
	}

}
